package com.woniu.humanresource.service.impl;

import com.woniu.humanresource.dao.SalaryDao;
import com.woniu.humanresource.entity.CorporateBenefits;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.entity.Salary;
import com.woniu.humanresource.entity.SalarysTructure;
import com.woniu.humanresource.service.SalarysService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
//薪酬表
@Service
public class SalarysServiceImpl implements SalarysService {

    @Resource
    SalaryDao salaryDao;

    //添加
    @Override
    public void insertSalary(Salary salary) {
        salaryDao.insertSalary(salary);
    }
    //查询
    @Override
    public PageBean<Salary> selectSalary(Salary salary, int pageIndex, int pageSize) {
        //创建用于接收beanlist的对象
        List<Salary> salist = salaryDao.selectSalary(salary, 1, 10);
        //封装pagebean并赋值
        PageBean<Salary> pageBean=new PageBean<>();
        pageBean.setBeanList(salist);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectSalarycount(salary));
        return pageBean;
    }

    //删除
    @Override
    public void deleteSalary(int id) {
        salaryDao.deleteSalary(id);
    }

    //修改
    @Override
    public void updateSalary(Salary salary) {
        salaryDao.updateSalary(salary);
    }

    //条数
    @Override
    public int selectSalarycount(Salary salary) {
        int count = salaryDao.selectSalarycount(salary);
        return count;
    }
}
